

<?
	  include("/inc/header.html") {}
    ?>  

      <div class="panel panel">   
		      <div class="col-lg-12">
		       <div class="note note-danger">
		           <h3 class="box-heading">Tips</h3>
		           <p>
		           		1、字段长度单库总和最大长度不能超过21843！
		           </p>
		           <p>
		           		2、英文名称必须使用英文小写字母与下划线组合方式，例如:book_id
		           </p>
		       </div>
		 </div>
	          <div class="panel-body pan">
	              
	                  <div class="form-body pal">
	                      <div class="row">
	                          <div class="col-md-6">
	                              <div class="form-group">
	                               <label for="inputUsername" >中文名称 <span class='require'>*</span> </label>
	                                  <div class="input-icon right">
	                                      <input id="nameZh" type="text" class="form-control" onchange="pinYin(this.value)"/>
	                                  </div>
	                              </div>
	                          </div>
	                          <div class="col-md-6">
	                              <div class="form-group">
	                               <label for="inputUsername" >英文名称 <span class='require'>*</span> </label>
	                                  <div class="input-icon right">
	                                    <input id="nameEn" type="text" class="form-control" onchange="voluation(this.value,0);"/>
	                                  </div>
	                              </div>
	                          </div>
	                      </div>
	                      <div class="row">
	                          <div class="col-md-6">
	                              <div class="form-group">
	                                  <div class="input-icon right">   
	                                   <label for="inputUsername" >字段名称 <span class='require'>*</span> </label>
	                                      <input id="field" type="text" class="form-control" readonly="readonly" />
	                                  </div>
	                              </div>
	                          </div>
	                          <div class="col-md-6">
	                              <div class="form-group">
	                                  <div class="input-icon right">
	                                   <label for="inputUsername" >排序 <span class='require'>*</span> </label>
	                                      <input id="sort" type="text" class="form-control" />
	                                  </div>
	                              </div>
	                          </div>
	                            
	                      </div>
	                      <hr/>
	                      <div class="row">
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >公共字段  </label>
	                                  <select  id="commonDataProperty"  class="form-control" onchange="gradeChange()"> 
	                                   <option value="00">---请选择---</option>  
	                                  </select>
	                              </div>
	                          </div>     
	                          <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >数据类型 <span class='require'>*</span> </label>
	                                  <select  id="dataType"  class="form-control" onchange="grade()"> 
	                                  </select>
	                              </div>
	                          </div>
	                          
	                          <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >关联字典类  </label>
	                                  <select id="dict" class="form-control">
	                                  <option value="00">---请选择---</option>  
	                                  </select>
	                              </div>
	                          </div>
	                            <div class="col-md-6">
	                              <div class="form-group">
	                                  <div class="input-icon right">
	                                   <label for="inputUsername" >字段长度 <span class='require'>*</span> </label>
	                                      <input id="fieldLength" type="text"  class="form-control" />
	                                  </div>
	                              </div>
	                          </div>
	                      </div>
	                           <hr/>
	                        <div class="row">
	                          <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否多值 <span class='require'>*</span> </label>
	                                  <select  id="multiValued"  class="form-control">
	                                       <option value="0">false</option>
	                                       <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                          <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否必填 <span class='require'>*</span> </label>
	                                  <select  id="required"  class="form-control">
	                                       <option value="0">false</option>
	                                       <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否内容存储 <span class='require'>*</span> </label>
	                                  <select  id="stored"  class="form-control">
	                                       <option value="0">false</option>
	                                       <option value="1" selected>true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否建立索引<span class='require'>*</span> </label>
	                                  <select  id="indexed"  class="form-control">
	                                       <option value="0">false</option>
	                                       <option value="1" selected>true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否用作特性 <span class='require'>*</span> </label>
	                                  <select  id="termVectors"  class="form-control">
	                                       <option value="0">false</option>
	                                       <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                           <div id="showSeparator" class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >分隔符</label>
	                                 <div class="input-icon right">
	                                    <input id="separator"  type="text" class="form-control"/>
	                                  </div>    
	                               
	                              </div>                                                   
	                          </div>
	                      </div>
	                  		<hr/>
	                     <div class="row">
	                          <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否分面字段 <span class='require'>*</span> </label>
	                                  <select  id="faceted"  class="form-control">
	                                       <option value="0">false</option>
	                                       <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                          <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否排序字段 <span class='require'>*</span> </label>
	                                  <select  id="sortField"  class="form-control">
	                                       <option value="0">false</option>
	                                       <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                          <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否前台列表页显示 <span class='require'>*</span> </label>
	                                  <select  id="webListShow"  class="form-control">
	                                       <option value="0" >false</option>
	                                       <option value="1" >true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                          <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否前台详情页显示 <span class='require'>*</span> </label>
	                                  <select  id="webDetailShow"  class="form-control">
	                                  		<option value="1">true</option>
	                                       <option value="0">false</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否普通检索字段 <span class='require'>*</span> </label>
	                                  <select  id="generalSearchField"  class="form-control">
	                                 		 <option value="0">false</option>
	                                        <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否高级检索字段 <span class='require'>*</span> </label>
	                                  <select  id="advancedSearchField"  class="form-control">
	                                 		 <option value="0">false</option>
	                                        <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否二次检索字段 <span class='require'>*</span> </label>
	                                  <select  id="searchWithinResultsField"  class="form-control">
	                                 		 <option value="0">false</option>
	                                        <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否标红字段 <span class='require'>*</span> </label>
	                                  <select  id="highlightingField"  class="form-control">
	                                 		 <option value="0">false</option>
	                                        <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                       </div>
	                       <hr/>
	                      <div class="row">
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否导航页左侧聚类字段 <span class='require'>*</span> </label>
	                                  <select  id="navigationFacetedLeft"  class="form-control">
	                                 		<option value="0">false</option>
	                                        <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否导航页筛选字段 <span class='require'>*</span> </label>
	                                  <select  id="navigationFacetedRight"  class="form-control">
	                                 		<option value="0">false</option>
	                                        <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否导航页检索字段<span class='require'>*</span> </label>
	                                  <select  id="navigationSearchField"  class="form-control">
	                                 		<option value="0">false</option>
	                                        <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                            </div>
	                       <hr/>
	                      <div class="row">
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否产品库普通检索字段<span class='require'>*</span> </label>
	                                  <select  id="productGeneralSearchField"  class="form-control">
	                                 		<option value="0">false</option>
	                                        <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否产品库高级检索字段<span class='require'>*</span> </label>
	                                  <select  id="productAdvancedSearchField"  class="form-control">
	                                 		<option value="0">false</option>
	                                        <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否产品库分面字段<span class='require'>*</span> </label>
	                                  <select  id="productFaceted"  class="form-control">
	                                 		<option value="0">false</option>
	                                        <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否产品库列表显示<span class='require'>*</span> </label>
	                                  <select  id="productWebListShow"  class="form-control">
	                                 		<option value="0">false</option>
	                                        <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否产品库详情页显示 <span class='require'>*</span> </label>
	                                  <select  id="productWebDetailShow"  class="form-control">
	                                 		<option value="0">false</option>
	                                        <option value="1">true</option>
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                      </div>
	                         <hr/>
	                     <div class="row">
	                         <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否后台列表页显示 <span class='require'>*</span> </label>
	                                  <select  id="adminListShow"  class="form-control">
	                                        <option value="1">true</option>
	                                       <option value="0" selected>false</option>                 
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                           <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否后台详情页显示 <span class='require'>*</span> </label>
	                                  <select  id="adminDetailShow"  class="form-control">
	                                       <option value="1">true</option>
	                                       <option value="0">false</option>
	
	                                  </select>    
	                              </div>                                                   
	                          </div>
	                      <div class="col-md-6">
	                              <div class="form-group"><label for="inputUsername" >是否关联展示首显项 <span class='require'>*</span> </label>
	                                  <select  id="relevanceClassShowField"  class="form-control">
	                                        <option value="1">true</option>
	                                       <option value="0" selected>false</option>                                                            
	                                  </select>    
	                              </div>                                                   
	                          </div>                                      
	                      <div class="col-md-6"> 
	                              <div class="form-group">
	                                  <div class="input-icon right">
	                                   <label for="inputUsername" >表单验证规则  </label>
	                                      <input id="formValidationRegulation" type="text" value="" class="form-control" />
	                                  </div>                                                  
	                          </div>
	                     </div>
	                  </div>
	               </div>
	          </div>
	      </div>   

  
 <script>

		var classid = window.parent.getclassid();
		var order = window.parent.getorder();
		var id = window.parent.getid();
		var gradeChangeId=0;
		$(function() {
			$("#sort").val(order);
			if($("#multiValued").val()==0){
				$("#showSeparator").hide();
			}
			commonDataPropertydata();
			 	document.getElementById('dict').disabled = true;
		});
		
		$(document).ready(function () { 
		  $("#multiValued").bind("change",function(){ 
		    if($(this).val()==1){
		   		$("#showSeparator").show();
		    }else{
		    	$("#showSeparator").hide();
		    } 
		  }); 
		});
		
		//字典下拉
		function dictdata() {
			$.ajax({
				type : "post",
				url : "./DictListall.do",
				data : {},
				dataType : "json",
				success : function(data) {
					$(data).each(
							function(n) {
								$("<option/>").html(data[n].nameZh).val(
										data[n].id).appendTo("#dict");
							});
							if(id!=0){
								 edit();
								}

				},
				error : function(data) {
					alert("请求失败");
				}
			});
			
		}
      
		
		//公用数据属性下拉
		function commonDataPropertydata() {
			$.ajax({
						type : "post",
						url : "./KnowledgeCommonDataPropertyListall.do",
						data : {},
						dataType : "json",
						success : function(data) {
							$(data).each(function(n) {
								$("<option/>").html(data[n].nameZh).val(data[n].id).appendTo("#commonDataProperty");
							});
							dataTypedata();
						},
						error : function(data) {
							alert("请求失败");
						}
					});
			
		}
		//数据属性下拉；
		function dataTypedata() {
			$.ajax({
				type : "post",
				url : "./KnowledgeListall.do",
				data : {},
				dataType : "json",
				success : function(data) {
					$(data).each(
							function(n) {
								$("<option/>").html(data[n].nameZh).val(
										data[n].id).appendTo("#dataType");
							});
							dictdata();
				},
				error : function(data) {
					alert("请求失败");
				}
			});

		
		}

		//联动显示函数1
		function gradeChange() {
			gradeChangeId = 1;
			var objS = document.getElementById("commonDataProperty");
			var gradeid = objS.options[objS.selectedIndex].value;
			if ("00" == gradeid) {
				document.getElementById('dataType').disabled = false;
				document.getElementById('multiValued').disabled = false;
				document.getElementById('required').disabled = false;
				document.getElementById('stored').disabled = false;
				document.getElementById('indexed').disabled = false;
				document.getElementById('termVectors').disabled = false;
				//document.getElementById('dict').disabled = false;
			} else {
				$.getJSON('./KnowledgeCommonDataedit.do',
					{
						id : gradeid
					},
					function(res) {
					    $("#field").val(res[0].field);	
					    $("#nameEn").val(res[0].nameEn); 
					    
					
					    if(res[0].dataTypeId != null){
						selected("dataType", res[0].dataTypeId);
						grade();
						}
						if(res[0].dictId!=null)
					    {
						selected("dict", res[0].dictId);
						}
						$("#fieldLength").val(res[0].fieldLength); 
						selected("multiValued", res[0].multiValued);
						if(res[0].multiValued==1){
							$("#showSeparator").show();
						}
						selected("required", res[0].required);
						selected("stored", res[0].stored);
						selected("indexed", res[0].indexed);
						selected("termVectors", res[0].termVectors);
						selected("generalSearchField", res[0].generalSearchField);
						selected("advancedSearchField", res[0].advancedSearchField);
						selected("searchWithinResultsField", res[0].searchWithinResultsField);
						selected("highlightingField", res[0].highlightingField);
						selected("productGeneralSearchField", res[0].productGeneralSearchField);
						selected("productAdvancedSearchField", res[0].productAdvancedSearchField);
						document.getElementById('dataType').disabled = true;
						document.getElementById('multiValued').disabled = true;
						document.getElementById('required').disabled = false;
						document.getElementById('stored').disabled = true;
						document.getElementById('indexed').disabled = true;
						document.getElementById('nameEn').disabled = true;
						document.getElementById('termVectors').disabled = true;
						voluation(res[0].nameEn,1);	
					});
			}

		}

		//保存编辑
		function save() {
		if(classid!=null)
		{
		if ($.trim($("#nameEn").val()).length < 1) {
				alert('英文名不能为空！');
				return null;
			}
			if ($.trim($("#nameZh").val()).length < 1) {
				alert('中文名不能为空！');
				return null;
			}
		     if ($.trim($("#sort").val()).length < 1) {
				alert('排序不能为空！');
				return null;
			}
			if (isNaN($("#sort").val())) {
				alert("排序必须是数字");
				return null;
			}
			 if ($.trim($("#fieldLength").val()).length < 1) {
				alert('长度不能为空！');
				return null;
			}
			if (isNaN($("#fieldLength").val())) {
				alert("长度必须是数字");
				return null;
			}
			var count = "";
			
					
			$.ajax({
						type : "post",
						url : "./KnowledgeDataPropertysave.do",
						data : {
							"id" : id,
							"classid" : classid,
							"nameEn" : $("#nameEn").val(),
							"nameZh" : $("#nameZh").val(),
							"sort" : $("#sort").val(),
							"separator" : $("#separator").val(),
							"commonDataProperty" : $("#commonDataProperty").val(),
							"multiValued" : $("#multiValued").val() ,
							 "required" : $("#required").val(),
							 "stored" : $("#stored").val(),
							 "indexed" : $("#indexed").val() ,
							 "termVectors" : $("#termVectors").val() ,
							 "faceted" : $("#faceted").val() ,
							 "sortField" : $("#sortField").val() ,
							 "webListShow" : $("#webListShow").val() ,
							 "webDetailShow" : $("#webDetailShow").val(),
							 "adminListShow" : $("#adminListShow").val(),
							 "adminDetailShow" : $("#adminDetailShow").val(),
							 "relevanceClassShowField" : $("#relevanceClassShowField").val(),
							"formValidationRegulation" : $("#formValidationRegulation").val(),
							"field" : $("#field").val(),
							"fieldLength" : $("#fieldLength").val(),
							"dataType" : $("#dataType").val(),
							"dict" : $("#dict").val(),
							"generalSearchField" : $("#generalSearchField").val(),
							"advancedSearchField" : $("#advancedSearchField").val(),
							"searchWithinResultsField" : $("#searchWithinResultsField").val(),
							"highlightingField" : $("#highlightingField").val(),
							"navigationFacetedLeft" : $("#navigationFacetedLeft").val(),
							"navigationFacetedRight" : $("#navigationFacetedRight").val(),
							"navigationSearchField" : $("#navigationSearchField").val(),
							"productGeneralSearchField" : $("#productGeneralSearchField").val(),
							"productAdvancedSearchField" : $("#productAdvancedSearchField").val(),
							"productFaceted" : $("#productFaceted").val(),
							"productWebListShow" : $("#productWebListShow").val(),
							"productWebDetailShow" : $("#productWebDetailShow").val(),
						},
						dataType : "json",
						async : false,
						success : function(data) {
							var index = parent.layer.getFrameIndex(window.name);
							//alert(JSON.stringify(data));
							if(data == 'ok'){
								parent.layer.msg('添加或编辑成功');
							}else{
								parent.layer.msg('添加或编辑失败，字段长度单库总和！');
							}
							window.parent.xianshidata();
							parent.layer.close(index);
						},
						error : function(data) {
							alert("请求失败");
						}
					});
					}
					else{
					   alert("你没有选中类！！！！");
					}

		}
		//编辑函数
		function edit() {
			$.getJSON('./KnowledgeDataPropertyedit.do',
			{
				id : id
			},
			function(res) {
				//alert(JSON.stringify(res));
				for(var i=0; i<res.length;i++){
						$("#nameEn").val(res[i].text.nameEn);
						document.getElementById('nameEn').disabled = true;
						$("#nameZh").val(res[i].text.nameZh);
						$("#sort").val(res[i].text.sort);
						$("#field").val(res[i].text.field);
						    if(res[i].text.multiValued==1){
								$("#showSeparator").show();
							}
						$("#separator").val(res[i].text.separator);
						$("#fieldLength").val(res[i].text.fieldLength);
						$("#formValidationRegulation").val(res[i].text.formValidationRegulation);
						if (res[i].commonDataProperty != null) {
							selected("commonDataProperty",res[i].commonDataProperty.id);
							selected("multiValued", res[i].text.multiValued);
							selected("required", res[i].text.required);
							selected("stored", res[i].text.stored);
							selected("indexed", res[i].text.indexed);
							selected("termVectors", res[i].text.termVectors);
							document.getElementById('multiValued').disabled = true;
		                    document.getElementById('required').disabled = false;
		                    document.getElementById('stored').disabled = true;
		                    document.getElementById('indexed').disabled = true;
		                    document.getElementById('termVectors').disabled = true;
							
						} else {
							selected("multiValued", res[i].text.multiValued);
							selected("required", res[i].text.required);
							selected("stored", res[i].text.stored);
							selected("indexed", res[i].text.indexed);
							selected("termVectors", res[i].text.termVectors);
						}
						
						if (res[i].dataType!=null) {
							selected("dataType", res[i].dataType.id);
						}
						if (res[i].dict!=null) {
							selected("dict", res[i].dict.id);
						}
						document.getElementById('nameEn').disabled = true;
						document.getElementById('nameZh').disabled = false;
						document.getElementById('dataType').disabled = true;
						document.getElementById('commonDataProperty').disabled = true;
						document.getElementById('fieldLength').disabled = true;
						selected("faceted", res[i].text.faceted);
						selected("sortField", res[i].text.sortField);
						selected("webListShow", res[i].text.webListShow);
						selected("webDetailShow",res[i].text.webDetailShow);
						selected("adminListShow", res[i].text.adminListShow);
						selected("adminDetailShow",res[i].text.adminDetailShow);
						selected("relevanceClassShowField",res[i].text.relevanceClassShowField);
						selected("generalSearchField", res[i].text.generalSearchField);
						selected("advancedSearchField", res[i].text.advancedSearchField);
						selected("searchWithinResultsField", res[i].text.searchWithinResultsField);
						selected("highlightingField", res[i].text.highlightingField);
						selected("navigationFacetedLeft", res[i].text.navigationFacetedLeft);
						selected("navigationFacetedRight", res[i].text.navigationFacetedRight);
						selected("navigationSearchField", res[i].text.navigationSearchField);
						selected("productGeneralSearchField", res[i].text.productGeneralSearchField);
						selected("productAdvancedSearchField", res[i].text.productAdvancedSearchField);
						selected("productFaceted", res[i].text.productFaceted);
						selected("productWebListShow", res[i].text.productWebListShow);
						selected("productWebDetailShow", res[i].text.productWebDetailShow);
				}
			});
		};
		//   默认单选函数
		function selected(selectname, selectid) {
			$("#" + selectname + " option").each(function() { //遍历全部option
				var v = $(this).val(); //获取option的内容
				if (v == selectid) {
					$(this).attr("selected", "selected");
				}
			});
		}
	 //赋值函数
  function voluation(nameen,kk) {
	 if ($.trim(nameen).length < 1) {
		alert('英文名不能为空！');
		return null;
	}
	if ($.trim(nameen).length > 32) {
		alert('英文名长度过长！');
		$("#nameEn").val("");
		$("#field").val("");
		return null;
	}
		var reg = "^[a-z_]+$";     
        var r = nameen.match(reg);
        if(r != null){
	        	$.ajax({
				type : "post",
				url : "./KnowledgeDataPropertyProving.do",
				data : {
				    "id":classid,
					"name" : nameen,
					"commonDataProperty":$("#commonDataProperty").val()
				},
				async : false,
				dataType : "json",
				success : function(data) {
				
					if(data.result==2){
						alert("表名不可用，已存在该公共字段");
						$("#nameEn").val("");
						if(kk==1){
							selected("commonDataProperty","00");
							document.getElementById('dataType').disabled = false;
							document.getElementById('multiValued').disabled = false;
							document.getElementById('required').disabled = false;
							document.getElementById('stored').disabled = false;
							document.getElementById('indexed').disabled = false;
							document.getElementById('termVectors').disabled = false;
							document.getElementById('nameEn').disabled = false;
						}
						
					}
					if(data.result==3){
						alert("表名不可用，不符合规则！");
						$("#nameEn").val("");
					}
					if(data.result==4){
						alert("表名不可用，必须为英文名！");
						$("#nameEn").val("");
						
					}
					if(data.result==5){
						alert("表名不可用，与公共字段冲突！");
						$("#nameEn").val("");
						
					}
					if(data.result==6){
						alert("表名不可用，已存在该表名！");
						$("#nameEn").val("");
					}
				},
				error : function(data) {
					alert("请求失败");
				}
			});
        }else{
        	alert("命名不规范，命名必须全小写，如有多个需隔开请以英文下划线分割（例：word_name）");
			$("#nameEn").val("");
        } 
 	$("#field").val($("#nameEn").val());
  }
  //单选框联动
  function grade() {
    var objS = document.getElementById("dataType");
	var dataTypeid = objS.options[objS.selectedIndex].value;
	if(dataTypeid==10||dataTypeid==9){
		$("#fieldLength").val("11");
		document.getElementById('fieldLength').disabled = true;
	}else if(dataTypeid==5||dataTypeid==6||dataTypeid==4)
	{
	$("#fieldLength").val("0");
	document.getElementById('fieldLength').disabled = true;
	}else
	{
		$("#fieldLength").val("");
		document.getElementById('fieldLength').disabled = false;
	}
	
  	if(dataTypeid=="7" || dataTypeid=="20"){
			document.getElementById('dict').disabled = false;
	}
	else{
	$("#dict").val("00");
	document.getElementById('dict').disabled = true;
	}
  }
  
  //汉字转拼音
 function pinYin(pinyinName){
	 var cdp =$("#commonDataProperty").val();
 	if(id==0){
 		if(cdp == 00){
 		var reg = "[A-Z]+";     
        var r = pinyinName.match(reg);
        if(r == null){
			 if(id == 0  && cdp == 00){
				$.ajax({
					type : "post",
					url : "hanziToinitial.do",
					data : {
						"pinYin" : pinyinName,
						"dp":"yes"
					},
					async : false,
					dataType : "json",
					success : function(data) {
						if(data == 'no'){
							layer.msg('自动转换英文名已存在!请手动输入！');
						}else{
							if(data[0].length > 32){
								layer.msg('自动转换英文名长度过长!请手动输入！');
								$("#nameEn").val("");
								$("#field").val("");
							}else{
								$("#nameEn").val(data);
								$("#field").val(data);
							}
						}
					},
					error : function(data) {
						alert("请求失败");
					}
				})
			}
		}else{
			alert("英文名不可存在大写，请手动输入英文名");
			$("#nameEn").val("");
			$("#field").val("");
		}
		}
	}
 }

function fieldLengthvoluation(fieldLengthId){
	if($("#dataType").val() == 2 || $("#dataType").val() == 3 ){
		//if(fieldLengthId > 255){
		//$("#fieldLength").val("");
		//layer.msg('长度过长！长度应小于等于255');
		//}
	}
}
</script>



